import Vue from 'vue'
import VueRouter from 'vue-router'

// 引入页面组件
import Index from '@/pages/Index/Index'
import Categories from '@/pages/Categories/Categories'
import ShopCart from '@/pages/ShopCart/ShopCart'
import Profile from '@/pages/Profile/Profile'
import Login from '@/pages/Login/Login'

const Search = () => import('@/pages/Search/Search')
const GoodsInfo = () => import ('@/pages/GoodsInfo/GoodsInfo')

Vue.use(VueRouter)
export default new VueRouter({
  routes: [
    {
      path: '/',
      redirect: '/index'
    },
    {
      path: '/index',
      component: Index,
      meta: {
        showFooter: true
      }
    },
    {
      path: '/categories',
      component: Categories,
      meta: {
        showFooter: true
      }
    },
    {
      path: '/shopcart',
      component: ShopCart,
      meta: {
        showFooter: true
      }
    },
    {
      path: '/profile',
      component: Profile,
      meta: {
        showFooter: true,
        requireAuth: true
      }
    },
    {
      path: '/login',
      component: Login
    },
    {
      path: '/search',
      component: Search,
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/goodsinfo/:id',
      component: GoodsInfo,
      name: 'goodsinfo'
    },
    {
      path: '*',
      redirect: '/'
    }
  ],
  mode: 'history'
})
